package cn.hncu.booksManagementSystem.stock.business.ebo;

import java.util.Collection;

import cn.hncu.booksManagementSystem.stock.business.ebi.StockEbi;
import cn.hncu.booksManagementSystem.stock.dao.dao.StockDAO;
import cn.hncu.booksManagementSystem.stock.dao.factory.StockDaoFactory;
import cn.hncu.booksManagementSystem.stock.vo.StockModel;
import cn.hncu.booksManagementSystem.stock.vo.StockQueryModel;
/**
 * CreateTime: 2018年4月23日 下午2:31:27	
 * @author 宋进宇  Email:447441478@qq.com
 */
public class StockEbo implements StockEbi{

	//注入dao
	private StockDAO dao = StockDaoFactory.getStockDAO();
	

	@Override
	public StockModel getByBookId(String bookId) {
		StockQueryModel sqm = new StockQueryModel();
		sqm.setBookId(bookId);
		Collection<StockModel> resCol = dao.getStocksInfoByCondition(sqm);
		if (resCol!=null&&resCol.size()>0) {
			for (StockModel stock : resCol) {
				return stock;
			}
		}
		return null;
	}

	@Override
	public Collection<StockModel> getAll() {
		return dao.getAll();
	}

	@Override
	public Collection<StockModel> getStocksByCondition(StockQueryModel sqm) {
		return dao.getStocksInfoByCondition(sqm);
	}

}
